#include "ASFTSettingScreen.h"
#include "ASScreenMgr.h"
#include "ASScreenShare.h"
#include "..\app\ASAppConst.h"
#include "..\app\ASApp.h"
#include "ASConfirmScreen.h"
#include "..\app\ASFTData.h"
#include "..\app\ASFTIo.h"
#include "..\control\ASButton.h"
#include "ASCustomScreen.h"
#include "..\control\ASScrollText.h"
#include "ASFTTypeScreen.h"
#include "ASPopupScreen.h"

static as_ft_setting_screen* s_as_ft_setting_scr_p;

static void as_ft_setting_reset_default(void)
{
    as_custom_screen_set_if_goback_reload(ASTRUE);
    as_ft_reset_default();
    as_screen_go_back();
}

static void as_ft_show_reset_default_confirm(void)
{
    as_show_confirm_screen(TEXT_RESET_DEFAULT_CONFIRM, TEXT_OK, TEXT_CANCEL,
                           as_ft_setting_reset_default, as_screen_go_back);
}

static void as_ft_setting_screen_add_listitem(as_list* list_p, as_rect pos, ASSTR text, as_void_func func)
{
    as_listitem* li_p;
    as_label* lb_p;
    ASUINT param[4];
    li_p = list_p->add_item((as_control*)list_p, pos);

    if(li_p)
    {
        li_p->set_bg_color((as_control*)li_p, DATA_SHEET_BG_COLOR);
        li_p->set_bg_selected_image((as_control*)li_p, as_ufg_tmp(0, IMG_NML_LIST_HL), AS_IMAGE_FROM_RES);

        if(func)
            li_p->set_pen_up_cb((as_control*)li_p, (as_listitem_cb)func);

        param[0] = (ASUINT)as_ucs2_from_gb2312(text);
        lb_p = (as_label*)li_p->add_ctrl((as_control*)li_p, AS_CTRL_LABEL, pos, 1, (void**)param);

        if(lb_p)
        {
            lb_p->set_text_color((as_control*)lb_p, EDIT_TEXT_COLOR);
            lb_p->set_bg_hidden((as_control*)lb_p, ASTRUE);
            lb_p->set_layout((as_control*)lb_p, AS_LABEL_TEXT_LEFT | AS_LABEL_TEXT_V_CENTER);
        }
    }
}

static void as_ft_setting_screen_gen_list(as_list* list_p)
{
    as_rect pos;
    as_memcpy(&pos, &list_p->base.area, sizeof(as_rect));
    pos.h = NORMAL_LIST_ITEM_H;
    //as_ft_setting_screen_add_listitem(list_p,pos,TEXT_HOMEPAGE_SETTING,as_enter_ft_setting_homepage_mgr_screen);
    //pos.y += pos.h;
    as_ft_setting_screen_add_listitem(list_p, pos, TEXT_INCOME_TYPE_MGR, as_enter_ft_setting_income_type_mgr_screen);
    pos.y += pos.h;
    as_ft_setting_screen_add_listitem(list_p, pos, TEXT_PAY_TYPE_MGR, as_enter_ft_setting_pay_type_mgr_screen);
    pos.y += pos.h;
    as_ft_setting_screen_add_listitem(list_p, pos, TEXT_MEMBER_TYPE_MGR, as_enter_ft_setting_member_mgr_screen);
    pos.y += pos.h;
    as_ft_setting_screen_add_listitem(list_p, pos, TEXT_RESET_DEFAULT, as_ft_show_reset_default_confirm);
    list_p->set_selected_idx((as_control*)list_p, 0);
}

static void as_ft_setting_screen_create_list(as_screen* screen_p, as_rect area)
{
    as_list* list_p = (as_list*)screen_p->add_ctrl(screen_p, AS_CTRL_LIST, area, 0, ASNULL);

    if(!list_p)
        return;

    list_p->set_bg_color((as_control*)list_p, DATA_SHEET_BG_COLOR);
    s_as_ft_setting_scr_p->list_p = list_p;
    as_ft_setting_screen_gen_list(s_as_ft_setting_scr_p->list_p);
}

static void as_ft_setting_screen_lsk(void)
{
    if(s_as_ft_setting_scr_p && s_as_ft_setting_scr_p->list_p)
    {
        if(s_as_ft_setting_scr_p->list_p->select_item && s_as_ft_setting_scr_p->list_p->select_item->pen_up_cb)
        {
            s_as_ft_setting_scr_p->list_p->select_item->pen_up_cb(s_as_ft_setting_scr_p->list_p->select_item);
        }
    }
}

static void as_ft_setting_screen_create_bottom_bar(as_screen* screen_p, as_rect area)
{
    as_button* btn_p;
    as_screen_create_bar_img(screen_p, area, IMG_BOTTOM);
    area.w = TEXT_SK_W;
    btn_p = as_screen_create_lsk(screen_p, area, TEXT_SELECT, as_ft_setting_screen_lsk);

    if(btn_p)
        btn_p->add_keycode((as_control*)btn_p, AS_KEY_OK);

    area.w = TEXT_SK_W;
    area.x = SCR_W - area.w;
    as_screen_create_rsk(screen_p, area, TEXT_BACK, as_show_custom_screen_from_child);
}

void as_ft_setting_screen_init(as_screen* screen_p)
{
    as_rect area;

    if(!screen_p)
        return;

    screen_p->set_bg_color(screen_p, DATA_SHEET_BG_COLOR);
    s_as_ft_setting_scr_p = (as_ft_setting_screen*)screen_p;
    area.x = 0;
    area.y = as_app_get_advbar_height();
    area.w = SCR_W;
    area.h = SMALL_TOP_BAR_H;
    as_screen_create_title_bar(screen_p, area, IMG_SMALL_TOP, IMG_TITLE_SETTING);
    //area.x += 2;
    //area.w = SCR_W - area.x * 2;
    area.y += area.h;
    area.h = SCR_H - BOTTOM_BAR_HEIGHT - area.y;
    as_ft_setting_screen_create_list(screen_p, area);
    area.w = SCR_W;
    area.h = BOTTOM_BAR_HEIGHT;
    area.x = 0;
    area.y = SCR_H - area.h;
    as_ft_setting_screen_create_bottom_bar(screen_p, area);

    if(as_app_get_show_advbar())
    {
        area.x = area.y = 0;
        area.w = SCR_W;
        as_screen_add_advbar(screen_p, area);
    }
}
void as_ft_setting_screen_deinit(as_screen* screen_p)
{
    AS_UNUSED(screen_p);
}
void as_enter_ft_setting_screen(void)
{
    as_screen_manager* scr_mgr_p = as_get_screen_stack_instance();
    as_screen* scr_p;
    scr_mgr_p->new_and_push_screen(AS_SCREEN_FTSETTING);
    scr_p = scr_mgr_p->get_cur_screen();

    if(scr_p)
    {
        scr_p->paint_hdlr(scr_p);
        scr_p->flush_hdlr(scr_p);
    }

    as_custom_screen_set_if_goback_reload(ASFALSE);
}

static as_ft_setting_type s_as_ft_setting_type;
static as_ft_setting_sub_screen* s_as_ft_setting_sub_scr_p;

static void as_ft_setting_sub_screen_set_type(as_ft_setting_type type)
{
    s_as_ft_setting_type = type;
}

static as_ft_setting_type as_ft_setting_sub_screen_get_type(void)
{
    return s_as_ft_setting_type;
}

ASSTR as_ft_setting_screen_get_opt_str(as_ft_setting_option opt)
{
    switch(opt)
    {
        case AS_FT_SETTING_OPT_EDIT:
            return TEXT_EDIT;

        case AS_FT_SETTING_OPT_DELETE:
            return TEXT_DELETE;

        case AS_FT_SETTING_OPT_NEW:
            return TEXT_NEW;

        case AS_FT_SETTINF_OPT_PAY_SUB:
            return TEXT_ENTER_SUB_TYPE;

        default:
            return ASNULL;
    }
}

static void as_ft_setting_sub_screen_create_title_bar(as_screen* screen_p, as_rect area)
{
    ASSTR img;
    as_ft_setting_type type = as_ft_setting_sub_screen_get_type();

    switch (type)
    {
            //case AS_FT_SETTING_HOMEPAGE:
            //case AS_FT_SETTING_HOMEPAGE_SUB:
            //    img = IMG_TITLE_HOMEPAGE_MGR;
            //    break;
        case AS_FT_SETTING_INCOME_MGR:
            img = IMG_TITLE_INCOME_TYPE_MGR;
            break;

        case AS_FT_SETTING_PAY_MGR:
            img = IMG_TITLE_PAY_TYPE_MGR;
            break;

        case AS_FT_SETTING_MEMBER_MGR:
            img = IMG_TITLE_MEMBER_MGR;
            break;

        default:
            break;
    }

    as_screen_create_title_bar(screen_p, area, IMG_SMALL_TOP, img);
}

static void as_ft_setting_screen_enter_opt_screen(void);
static void as_ft_setting_sub_screen_lsk(void)
{
    //as_ft_setting_type type = as_ft_setting_sub_screen_get_type();
    if(s_as_ft_setting_sub_scr_p && s_as_ft_setting_sub_scr_p->list_p)
    {
        as_ft_setting_screen_enter_opt_screen();
        //if(s_as_ft_setting_sub_scr_p->list_p->select_item && s_as_ft_setting_sub_scr_p->list_p->select_item->pen_up_cb)
        //{
        //    s_as_ft_setting_sub_scr_p->list_p->select_item->pen_up_cb(s_as_ft_setting_sub_scr_p->list_p->select_item);
        //}
    }
}

static void as_ft_setting_sub_screen_rsk(void)
{
    as_screen_go_back();
}

static void as_ft_setting_sub_screen_create_bottom_bar(as_screen* screen_p, as_rect area)
{
    as_button* btn_p;
    as_screen_create_bar_img(screen_p, area, IMG_BOTTOM);
    area.w = TEXT_SK_W;
    btn_p = as_screen_create_lsk(screen_p, area, TEXT_OPTION, as_ft_setting_sub_screen_lsk);

    if(btn_p)
        btn_p->add_keycode((as_control*)btn_p, AS_KEY_OK);

    area.w = TEXT_SK_W;
    area.x = SCR_W - area.w;
    as_screen_create_rsk(screen_p, area, TEXT_BACK, as_ft_setting_sub_screen_rsk);
}

static ASSTR as_ft_setting_screen_get_homepage_cfg_str(as_ft_setting_homepage_cfg cfg)
{
    switch(cfg)
    {
        case AS_FT_SETTING_HP_CFG1:
            return TEXT_HOMEPAGE_1;

        case AS_FT_SETTING_HP_CFG2:
            return TEXT_HOMEPAGE_2;

        default:
            return ASNULL;
    }
}

static ASSTR as_ft_setting_screen_get_homepage_mgr_str(as_ft_setting_homepage_show_type type)
{
    switch(type)
    {
        case AS_FT_SETTING_HP_SHOW_PAY_DAYLY:
            return TEXT_PAY_DAYLY;

        case AS_FT_SETTING_HP_SHOW_PAY_WEEKLY:
            return TEXT_PAY_WEEKLY;

        case AS_FT_SETTING_HP_SHOW_PAY_MONTHLY:
            return TEXT_PAY_MONTHLY;

        case AS_FT_SETTING_HP_SHOW_PAY_YEARLY:
            return TEXT_PAY_YEARLY;

        case AS_FT_SETTING_HP_SHOW_INCOME_DAYLY:
            return TEXT_INCOME_DAYLY;

        case AS_FT_SETTING_HP_SHOW_INCOME_WEEKLY:
            return TEXT_INCOME_WEEKLY;

        case AS_FT_SETTING_HP_SHOW_INCOME_MONTHLY:
            return TEXT_INCOME_MONTHLY;

        case AS_FT_SETTING_HP_SHOW_INCOME_YEARLY:
            return TEXT_INCOME_YEARLY;

        default:
            return ASNULL;
    }
}

ASINT as_ft_setting_screen_get_level1_idx(void)
{
    return s_as_ft_setting_sub_scr_p->level_1_idx;
}

void as_ft_setting_screen_set_level1_idx(ASINT idx)
{
    s_as_ft_setting_sub_scr_p->level_1_idx = idx;
}

ASINT as_ft_setting_screen_get_level2_idx(void)
{
    return s_as_ft_setting_sub_scr_p->level_2_idx;
}

void as_ft_setting_screen_set_level2_idx(ASINT idx)
{
    s_as_ft_setting_sub_scr_p->level_2_idx = idx;
}

static void as_ft_setting_sub_screen_preselect_idx(as_list* list_p)
{
    as_ft_setting_type type = as_ft_setting_sub_screen_get_type();
    ASINT level_1_idx = s_as_ft_setting_sub_scr_p->level_1_idx;
    ASINT level_2_idx = s_as_ft_setting_sub_scr_p->level_2_idx;

    switch(type)
    {
            //case AS_FT_SETTING_HOMEPAGE:
        case AS_FT_SETTING_INCOME_MGR:
        case AS_FT_SETTING_PAY_MGR:
        case AS_FT_SETTING_MEMBER_MGR:
            list_p->set_selected_idx((as_control*)list_p, level_1_idx);
            break;

        case AS_FT_SETTING_HOMEPAGE_SUB:
            list_p->set_selected_idx((as_control*)list_p, level_2_idx);
            break;

        default:
            list_p->set_selected_idx((as_control*)list_p, 0);
            break;
    }

    list_p->adjust_select_item_position((as_control*)list_p);
}

#ifdef AS_FREE_PAY_ENABLE_IN_PHONE

static void as_ft_free_try_to_pay_for_setting(void);

static void as_ft_free_pay_for_setting_result_confirm_lsk(void)
{
    as_screen_go_back();
    as_ft_free_try_to_pay_for_setting();
}

static void as_ft_free_pay_for_setting_result_cb(as_ret result)
{
    as_screen_show_adv_bar();

    if(result == AS_OK)
    {
        as_ft_fp_for_setting_ok(as_ft_setting_sub_screen_get_type());
        as_show_popup_screen(TEXT_PAY_SUCCESSFUL);
    }
    else
    {
        as_show_confirm_screen(TEXT_FREE_PAY_FAILED, TEXT_OK, TEXT_CANCEL,
                               as_ft_free_pay_for_setting_result_confirm_lsk, as_screen_go_back);
    }
}

static void as_ft_free_try_to_pay_for_setting(void)
{
    as_ft_setting_type setting_type = as_ft_setting_sub_screen_get_type();
    ASINT point = setting_type - AS_FT_SETTING_INCOME_MGR + AS_FT_FP_INCOME_MGR;
    ASINT amount = FT_UNLOCK_TYPE_MGR_FP;
    as_free_pay_point_pay(point, amount,
                          as_ft_fp_get_point_brief(point), as_ft_fp_get_point_detail(point),
                          as_ft_free_pay_for_setting_result_cb);
}
#endif//AS_FREE_PAY_ENABLE_IN_PHONE


static void as_ft_setting_screen_enter_opt_screen(void)
{
    as_ft_setting_type type = as_ft_setting_sub_screen_get_type();

    if(type == AS_FT_SETTING_INCOME_MGR
       || type == AS_FT_SETTING_MEMBER_MGR
       || type == AS_FT_SETTING_PAY_MGR)
    {
        s_as_ft_setting_sub_scr_p->level_1_idx = s_as_ft_setting_sub_scr_p->list_p->select_idx;

        if(s_as_ft_setting_sub_scr_p->list_p->item_counts == 0)
        {
            s_as_ft_setting_sub_scr_p->level_1_idx = -1;
        }
    }
    else if(type == AS_FT_SETTING_PAY_SUB_MGR)
    {
        s_as_ft_setting_sub_scr_p->level_2_idx = s_as_ft_setting_sub_scr_p->list_p->select_idx;

        if(s_as_ft_setting_sub_scr_p->list_p->item_counts == 0)
        {
            s_as_ft_setting_sub_scr_p->level_2_idx = -1;
        }
    }

    if(type == AS_FT_SETTING_INCOME_MGR)
        as_fttype_enter_income_mgr_opt_screen();
    else if(type == AS_FT_SETTING_MEMBER_MGR)
        as_fttype_enter_member_mgr_opt_screen();
    else if(type == AS_FT_SETTING_PAY_MGR)
        as_fttype_enter_pay_mgr_opt_screen();
    else if(type == AS_FT_SETTING_PAY_SUB_MGR)
        as_fttype_enter_pay_sub_mgr_opt_screen();
}

static void as_ft_setting_sub_screen_gen_content(as_list* list_p)
{
    as_ft_setting_type type = as_ft_setting_sub_screen_get_type();
    ASINT cnts, i;
    as_listitem* li_p;
    as_scrolltext* st_p;
    as_rect pos;
    ASUINT param[4];
    ASFILE fh = -1;
    ASWSTR buf = as_ft_get_tmp_wstr();

    switch(type)
    {
            //case AS_FT_SETTING_HOMEPAGE:
            //    cnts = AS_FT_SETTING_HP_CFG_MAX;
            //    break;
            //case AS_FT_SETTING_HOMEPAGE_SUB:
            //    cnts = AS_FT_SETTING_HP_SHOW_MAX;
            //    break;
        case AS_FT_SETTING_INCOME_MGR:
            fh = as_ft_file_open(ASFT_FILE_INCOMETYPE, -1, AS_FILE_RO);

            if(fh <= 0)
                return;

            cnts = as_ft_file_get_data_cnts(fh);
            break;

        case AS_FT_SETTING_PAY_MGR:
            fh = as_ft_file_open(ASFT_FILE_PAYTYPE, -1, AS_FILE_RO);

            if(fh <= 0)
                return;

            cnts = as_ft_file_get_data_cnts(fh);
            break;

        case AS_FT_SETTING_PAY_SUB_MGR:
            fh = as_ft_file_open(ASFT_FILE_PAYTYPE, as_ft_setting_screen_get_level1_idx(), AS_FILE_RO);

            if(fh <= 0)
                return;

            cnts = as_ft_file_get_data_cnts(fh);
            break;

        case AS_FT_SETTING_MEMBER_MGR:
            fh = as_ft_file_open(ASFT_FILE_MEMBER, -1, AS_FILE_RO);

            if(fh <= 0)
                return;

            cnts = as_ft_file_get_data_cnts(fh);
            break;
    }

    as_memcpy(&pos, &list_p->base.area, sizeof(as_rect));
    pos.h = NORMAL_LIST_ITEM_H;

    for(i = 0; i < cnts; i++)
    {
        li_p = list_p->add_item((as_control*)list_p, pos);

        if(li_p)
        {
            li_p->set_bg_color((as_control*)li_p, DATA_SHEET_BG_COLOR);
            li_p->set_bg_selected_image((as_control*)li_p, as_ufg_tmp(0, IMG_NML_LIST_HL), AS_IMAGE_FROM_RES);

            //if(type == AS_FT_SETTING_HOMEPAGE)
            //    param[0] = (ASUINT)as_ucs2_from_gb2312(as_ft_setting_screen_get_homepage_cfg_str(i));
            //else if(type == AS_FT_SETTING_HOMEPAGE_SUB)
            //    param[0] = (ASUINT)as_ucs2_from_gb2312(as_ft_setting_screen_get_homepage_mgr_str(i));
            if(type == AS_FT_SETTING_INCOME_MGR)
            {
                as_ft_file_get_data(fh, FT_RECORD_INCOMETYPE_TOP_MAX, buf, sizeof(ASWCHAR)*FT_RECORD_TYPE_NAME_LEN, i);
                param[0] = (ASUINT)buf;
            }
            else if(type == AS_FT_SETTING_PAY_MGR)
            {
                as_ft_file_get_data(fh, FT_RECORD_PAYTYPE_TOP_MAX, buf, sizeof(ASWCHAR)*FT_RECORD_TYPE_NAME_LEN, i);
                param[0] = (ASUINT)buf;
            }
            else if(type == AS_FT_SETTING_PAY_SUB_MGR)
            {
                as_ft_file_get_data(fh, FT_RECORD_PAYTYPE_SUB_MAX, buf, sizeof(ASWCHAR)*FT_RECORD_TYPE_NAME_LEN, i);
                param[0] = (ASUINT)buf;
            }
            else if(type == AS_FT_SETTING_MEMBER_MGR)
            {
                as_ft_file_get_data(fh, FT_RECORD_MEMBER_MAX, buf, sizeof(ASWCHAR)*FT_RECORD_MEMBER_NAME_LEN, i);
                param[0] = (ASUINT)buf;
            }

            //else if(type == )
            param[1] = EDIT_TEXT_COLOR;
            param[2] = DATA_SHEET_BG_COLOR;
            st_p = (as_scrolltext*)li_p->add_ctrl((as_control*)li_p, AS_CTRL_SCROLLTEXT, pos, 3, (void**)param);

            if(st_p)
            {
                st_p->set_valid_show_area((as_control*)st_p, &list_p->base.area);
                st_p->set_focus_bg_img((as_control*)st_p, AS_IMAGE_FROM_RES, as_ufg_tmp(0, IMG_NML_LIST_HL));
            }

            li_p->set_pen_up_cb((as_control*)li_p, (as_listitem_cb)as_ft_setting_screen_enter_opt_screen);
        }

        pos.y += pos.h;
    }

    if(fh > 0)
        as_ft_file_close(fh);

    as_ft_setting_sub_screen_preselect_idx(list_p);
}


void as_ft_setting_sub_screen_update_content(void)
{
    as_list* list_p;

    if(!s_as_ft_setting_sub_scr_p)
        return;

    list_p = s_as_ft_setting_sub_scr_p->list_p;

    if(list_p->item_counts > 0)
        list_p->clean_items((as_control*)list_p);

    as_ft_setting_sub_screen_gen_content(list_p);
    list_p->base.paint_hdlr((as_control*)list_p);
    as_flush();
}

void as_ft_setting_screen_switchto_pay_sub_screen(void)
{
    as_ft_setting_sub_screen_set_type(AS_FT_SETTING_PAY_SUB_MGR);
    as_ft_setting_sub_screen_update_content();
}

static void as_ft_setting_sub_screen_create_content(as_screen* screen_p, as_rect area)
{
    as_list* list_p;
    list_p = (as_list*)screen_p->add_ctrl(screen_p, AS_CTRL_LIST, area, 0, ASNULL);

    if(list_p)
    {
        list_p->set_bg_color((as_control*)list_p, DATA_SHEET_BG_COLOR);
        as_ft_setting_sub_screen_gen_content(list_p);
        s_as_ft_setting_sub_scr_p->list_p = list_p;
    }
}

void as_ft_setting_sub_screen_init(as_screen* screen_p)
{
    as_rect area;

    if(!screen_p)
        return;

    s_as_ft_setting_sub_scr_p = (as_ft_setting_sub_screen*)screen_p;
    screen_p->set_bg_color(screen_p, DATA_SHEET_BG_COLOR);
    area.x = 0;
    area.y = as_app_get_advbar_height();
    area.w = SCR_W;
    area.h = SMALL_TOP_BAR_H;
    as_ft_setting_sub_screen_create_title_bar(screen_p, area);
    area.y += area.h;
    area.h = SCR_H - BOTTOM_BAR_HEIGHT - area.y;
    as_ft_setting_sub_screen_create_content(screen_p, area);
    area.h = BOTTOM_BAR_HEIGHT;
    area.y = SCR_H - area.h;
    as_ft_setting_sub_screen_create_bottom_bar(screen_p, area);

    if(as_app_get_show_advbar())
    {
        area.x = area.y = 0;
        area.w = SCR_W;
        as_screen_add_advbar(screen_p, area);
    }
}

void as_ft_setting_sub_screen_deinit(as_screen* screen_p)
{
}

static void as_enter_ft_setting_sub_screen(void)
{
    as_screen_manager* scr_mgr_p = as_get_screen_stack_instance();
    as_screen* scr_p;
    as_ft_setting_type type = as_ft_setting_sub_screen_get_type();
#ifdef AS_LOCAL_SCORE_ENABLE

    if(!as_ft_if_payed_for_setting(type))
    {
        if(as_ft_check_if_score_could_buy_mgr())
        {
            as_ft_add_score(-FT_UNLOCK_TYPE_MGR_FP);
            as_ft_fp_for_setting_ok(type);
        }
        else
        {
            as_show_popup_screen(TEXT_SCORE_NOT_ENOUGH);
            return;
        }
    }

#endif
#ifndef AS_VERSION_DEBUG
#ifdef AS_FREE_PAY_ENABLE_IN_PHONE

    if(!as_ft_if_payed_for_setting(type)
       && as_free_pay_point_check(type - AS_FT_SETTING_INCOME_MGR + AS_FT_FP_INCOME_MGR,
                                  as_ft_free_pay_for_setting_result_cb) != AS_OK
      )
    {
        as_ft_free_try_to_pay_for_setting();
        return;
    }

#endif
#endif
    scr_mgr_p->new_and_push_screen(AS_SCREEN_FTSETTING_SUB);
    scr_p = scr_mgr_p->get_cur_screen();

    if(scr_p)
    {
        scr_p->paint_hdlr(scr_p);
        scr_p->flush_hdlr(scr_p);
    }
}

void as_enter_ft_setting_homepage_mgr_screen(void)
{
    //as_ft_setting_sub_screen_set_type(AS_FT_SETTING_HOMEPAGE);
    //as_enter_ft_setting_sub_screen();
}

void as_enter_ft_setting_income_type_mgr_screen(void)
{
    as_ft_setting_sub_screen_set_type(AS_FT_SETTING_INCOME_MGR);
    as_enter_ft_setting_sub_screen();
}

void as_enter_ft_setting_pay_type_mgr_screen(void)
{
    as_ft_setting_sub_screen_set_type(AS_FT_SETTING_PAY_MGR);
    as_enter_ft_setting_sub_screen();
}

void as_enter_ft_setting_member_mgr_screen(void)
{
    as_ft_setting_sub_screen_set_type(AS_FT_SETTING_MEMBER_MGR);
    as_enter_ft_setting_sub_screen();
}

//void as_enter_ft_setting_local_pw_mgr_screen(void)
//{
//    as_ft_setting_sub_screen_set_type(AS_FT_SETTING_LOCAL_PW);
//    as_enter_ft_setting_sub_screen();
//}